/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package business;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Alberto
 */
@Entity
@Table(name = "reserva")
@NamedQueries({
    @NamedQuery(name = "Reserva.findAllByEstado", query = "SELECT a FROM Reserva a WHERE a.estado = :estado"),
    @NamedQuery(name = "Reserva.findByID", query="SELECT a FROM Reserva a WHERE a.idreserva = :idreserva"),
    @NamedQuery(name = "Reserva.findByAlumno", query = "SELECT a FROM Reserva a WHERE a.alumno = :alumno")

    })
public class Reserva implements Serializable {
    private static final long serialVersionUID = 1L;
  
    private Integer idreserva;
    private Alumno alumno;
    private Date fechareserva;
    private Habitacion habitacion;
    private String estado;

    public Reserva(Alumno alumno, Date fechareserva, Habitacion habitacion, String estado) {
        this.alumno = alumno;
        this.fechareserva = fechareserva;
        this.habitacion = habitacion;
        this.estado = estado;
    }

    public Reserva() {
    }

   

   

      @TableGenerator(
        name="reservaGen",
        table="JPA_GENERATOR",
        pkColumnName="GEN_KEY",
        valueColumnName="GEN_VALUE",
        pkColumnValue="RESERVA_ID",
        allocationSize=1,
        initialValue=2)
        @Id
    @Basic(optional = false)
    @GeneratedValue(strategy=GenerationType.TABLE,generator="reservaGen")
    @Column(name = "idreserva", nullable = false)
    public Integer getIdreserva() {
        return idreserva;
    }

    public void setIdreserva(Integer idreserva) {
        this.idreserva = idreserva;
    }

    @JoinColumn(name="idalumno",referencedColumnName="idalumno")
    @ManyToOne
    public Alumno getAlumno() {
        return alumno;
    }

    public void setAlumno(Alumno alumno) {
        this.alumno = alumno;
    }

    @Column(name = "fechareserva")
    @Temporal(value = TemporalType.TIMESTAMP)
    public Date getFechareserva() {
        return fechareserva;
    }

    public void setFechareserva(Date fechareserva) {
        this.fechareserva = fechareserva;
    }

     @JoinColumn(name = "idhabitacion",referencedColumnName="idhabitacion")
    @ManyToOne
    public Habitacion getHabitacion() {
        return habitacion;
    }

    public void setHabitacion(Habitacion habitacion) {
        this.habitacion = habitacion;
    }

    @Column(name = "estado")
    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idreserva != null ? idreserva.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reserva)) {
            return false;
        }
        Reserva other = (Reserva) object;
        if ((this.idreserva == null && other.idreserva != null) || (this.idreserva != null && !this.idreserva.equals(other.idreserva))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "business.Reserva[idreserva=" + idreserva + "]";
    }

}
